package model;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Alexey Kuprin
 */

public class ProductType {
	private String name;
	private List<Process> recipe;
	private List<Stack> stacks;

	public ProductType(String name) {
		this.name = name;
		recipe = new ArrayList<Process>();
		stacks = new ArrayList<Stack>();
	}

	public ProductType(String name, List<Process> p) {
		this(name);

		recipe.addAll(p);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void addProcess(Process p) {
		recipe.add(p);
	}

	public void addProcess(Process p, int index) {
		recipe.add(index, p);
	}

	public void removeProcess(Process p) {
		recipe.remove(p);
	}

	void addStack(Stack s) {
		if (!stacks.contains(s)) {
			stacks.add(s);
		}
	}

	void removeStack(Stack s) {
		stacks.remove(s);
	}

	public List<Process> getRecipe() {
		return new ArrayList<Process>(recipe);
	}

	public List<Stack> getStacks() {
		return new ArrayList<Stack>(stacks);
	}

	@Override
	public String toString() {
		return name;
	}

	public void setProcesses(List<Process> processes) {
		recipe.clear();
		recipe.addAll(processes);
	}

}
